﻿@{
    ViewBag.Title = "stDrupInfoUpt";
    Layout = "~/Views/Shared/_ViewMenu.cshtml";
}

@using ZX.HIS.Model;
@{
    List<ZX.HIS.Model.DrugTypeInfo> DrugTypeList = ViewData["liat"] as List<ZX.HIS.Model.DrugTypeInfo>;
    List<ZX.HIS.Model.OpenDose> opmode = ViewData["opmode"] as List<OpenDose>;
    List<ZX.HIS.Model.DrugUsage> DrugUsagemode = ViewData["DrugUsagemode"] as List<DrugUsage>;
    List<ZX.HIS.Model.MeasuringUnit> MeasuringUnitmode = ViewData["MeasuringUnitmode"] as List<MeasuringUnit>;
    List<ZX.HIS.Model.DrugFrequency> DrugFrequencymode = ViewData["DrugFrequencymode"] as List<DrugFrequency>;
    List<ZX.HIS.Model.Product> Productmode = ViewData["Productmode"] as List<ZX.HIS.Model.Product>;
}
<input type="hidden" id="DrugId" value="@ViewBag.DrugId" />
<script>
    $(function () {
        var id = $("#DrugId").val()
        $.ajax({
            type: "post",
            url: "/DrupInfo/DrupInfoJson/" + id,
            success: function (data) {
                $("#DrugName").val(data.DrugName);
                $("#DrugTypeId").val(data.DrugTypeId);
                $("#DrugPackSpece").val(data.DrugPackSpece);
                $("#OpenDoseName").val(data.OpenDoseName);
                $("#ProductId").val(data.ProductName);
                $("#DrugApprovalNo").val(data.DrugApprovalNo);
                $("#DrugPurchasePrice").val(data.DrugPurchasePrice);
                $("#DrugBarCode").val(data.DrugBarCode);
                $("#DrugPurchasePrice").val(data.DrugPurchasePrice);
                $("#DrugIsOtc").val(data.DrugIsOtc).attr("checked", true);
                $("#DrugState").val(data.DrugState).attr("checked", true);
            }
        })
        $.ajax({
            type: "post",
            url: "/DrupInfo/DrugInventoryJson/" + id,
            success: function (dta) {
                $("#DrugInvThrVal").val(dta.DrugInvThrVal);
                $("#DrugInvPresPrice").val(dta.DrugInvPresPrice);
                $("#SupplierId").val(dta.SupplierId);
                $("#tbDrugShelfCode").val(dta.tbDrugShelfCode);
            }
        })

        $.ajax({
            type: "post",
            url: "/DrupInfo/DrugUseInfoJson/" + id,
            success: function (dat) {

                $("#DrugUsageName").val(dat.DrugUsageName);
                $("#DrugUseIdMeasu").val(dat.DrugUseIdMeasu);
                $("#MeasuringUnitName").val(dat.MeasuringUnitName);
                $("#DrugFrequencyName").val(dat.DrugFrequencyName);
                $("#DrugUseOpenDose").val(dat.DrugUseOpenDose);
                $("#DocAdviceId").val(dat.DocAdviceId);
            }
        })
    })
</script>

<div class="fixed-panel top-fixed" id="top-fixed-panel">
    <div class="header">
        <table>
            <tr>
                <th><span class="header-title f-left"><i class="J_saveTypeTitle">新增</i>药品</span></th>
                <td> <button data-save-type="add" class="header-btn f-left J_save" id="ADD">保存</button></td>
                <td><a href="/DrupInfo/stDrupInfoIndex" class="header-btn f-left J_cancel">取消</a></td>
            </tr>
        </table>
    </div>
</div>
<div class="main-content-inner flt">
    <link href="~/Content/After/css/drugadd.css" rel="stylesheet" />

    <div class="main">
        <form id="J_drugInfo">
            <div class="main-form">
                <div class="main-form-block f-clrfix">
                    <div class="main-block-title">基本信息</div>
                    <div class="main-block-content">
                        <div class="main-con-col f-clrfix">
                            <div class="main-con-item col-md-4 sug-wrap">
                                <span class="main-item-desc"><i>*</i>药品名称：</span>
                                <input type="text" name="DrugName" placeholder="通用名/商品名/药品条码" id="DrugName" class="J_drugName J_createSug J_inputChar150" issug="1"><ul class="sug-ul-dom " style="border: 1px solid rgb(223, 223, 223); width: 400px; display: none;"></ul>
                            </div>
                            <div class="main-con-item col-md-4">
                                <span class="main-item-desc"><i>*</i>药品类型：</span>
                                <select class="select-drugtype J_drugType" name="drugType" id="DrugTypeId" data-change-way="add">
                                    <option value="0">请选择</option>
                                    @foreach (var item in DrugTypeList)
                                    {
                                        <option value="@item.DrugTypeId">@item.DrugTypeName</option>
                                    }
                                </select>
                            </div>
                            <div class="col-md-4">
                                <span class="main-item-desc J_otcText">OTC：</span>
                                <input name="b" value="1" type="radio" id="DrugIsOtc">是
                                <input name="b" value="0" checked="true" type="radio" id="DrugIsOtc">否
                            </div>
                        </div>
                        <div class="main-con-col f-clrfix">
                            <div class="main-con-item col-md-4 drug-spec">
                                <span class="main-item-desc"><i>*</i>包装规格：</span>
                                <div class="drug-spec-bigitem">
                                    <input type="text" name="specification" placeholder="规格包装描述" id="DrugPackSpece" class="J_inputChar50">
                                </div>
                                &nbsp;/
                                <div class="drug-spec-item sug-wrap">
                                    <input type="text" list="browses" name="specPackageUnit" placeholder="包装单位" id="OpenDoseName" maxlength="6" class="J_createSug">
                                    <datalist id="browses">
                                        @foreach (var item in opmode)
                                        {
                                            <option value="@item.OpenDoseName" />
                                        }
                                    </datalist>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <span class="main-item-desc">状态：</span>
                                <input checked="checked" name="c" value="1" type="radio" id="DrugState">启用
                                <input name="c" value="2" type="radio" id="DrugState">停用
                            </div>
                        </div>
                        <div class="main-con-col f-clrfix">
                            <div class="main-con-item col-md-4 sug-wrap">
                                <span class="main-item-desc"><i class="J_manufacturerRequire">*</i>生产厂家：</span>
                                <input type="text" list="browsrs" id="ProductId" name="manufacturer" class="J_searchSug J_createSug">
                                <datalist id="browsrs">
                                    @foreach (var item in Productmode)
                                    {
                                        <option value="@item.ProductId">@item.ProductName</option>
                                    }
                                </datalist>

                            </div>
                            <div class="main-con-item col-md-4">
                                <span class="main-item-desc">批准文号：</span>
                                <input type="text" name="approvalNumber" id="DrugApprovalNo" class="J_inputChar50">
                            </div>
                            <div class="main-con-item col-md-4 sug-wrap normal-sug">
                                <span class="main-item-desc">药品条形码：</span>
                                <input type="text" name="barCode" id="DrugBarCode" class="J_inputChar50 J_inputLetterNumber">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="main-form-block">
                    <div class="main-block-title">库存销售设置</div>
                    <div class="main-block-content f-clrfix">
                        <div class="main-con-col f-clrfix">
                            <div class="main-con-item col-md-4">
                                <span class="main-item-desc"><i>*</i>库存阈值：</span>
                                <input type="text" name="inventoryThreshold" maxlength="6" class="J_defaultValue J_inputIntZero" id="DrugInvThrVal" data-default-value="0"><i class="J_countUnit J_unit">0</i>
                            </div>
                            <div class="main-con-item col-md-4 J_specUnitWrap ">
                                <span class="main-item-desc "><i class="hide J_specUnitRequire">*</i>进货价：</span>
                                <div class="main-item-desc">
                                    <input type="text" id="DrugPurchasePrice" class="inpMain" />
                                </div>
                            </div>
                        </div>
                        <div class="main-con-col f-clrfix J_noBatch" style="display: none;"></div>
                        <div class="main-con-col f-clrfix">
                            <div class="main-con-item col-md-4">
                                <span class="main-item-desc">
                                    <i>*</i>
                                    处方价：
                                </span><input type="text" name="prescriptionPrice" id="DrugInvPresPrice" class="J_defaultValue J_inputFloatZero" data-default-value="0.00">&nbsp;元/<i class="J_countUnit J_unit"></i>
                                <span class="warn J_inputWarn"></span>
                            </div>
                            <div class="main-con-item col-md-4">
                                <span class="main-item-desc">供应商：</span>
                                <input type="text" name="supplier" id="SupplierId" class="J_inputChar100">
                            </div>
                            <div class="main-con-item col-md-4">
                                <span class="main-item-desc">货架码：</span>
                                <input type="text" name="goodsShelfCode" id="tbDrugShelfCode" class="J_inputChar50">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="main-form-block">
                    <div class="main-block-title">使用信息</div>
                    <div class="main-block-content f-clrfix">
                        <div class="main-con-col f-clrfix">
                            <div class="main-con-item col-md-4 sug-wrap normal-sug">
                                <span class="main-item-desc">用法：</span>
                                <input type="text" name="instruction" list="brwserss" id="DrugUsageName" class="J_createSug J_inputChar50">
                                <datalist id="brwserss">
                                    @foreach (var item in DrugUsagemode)
                                    {
                                        <option value="@item.DrugUsageName" />
                                    }
                                </datalist>

                            </div>
                            <div class="main-con-item col-md-4">
                                <span class="main-item-desc">单次剂量：</span>
                                <input type="text" name="singleDosage" placeholder="单次剂量" id="DrugUseIdMeasu" class="md-input J_inputChar30 J_dosage">
                                <div class="lt-input-wrap sug-wrap">
                                    <input type="text" list="browsersss" name="singleDosageUnit" placeholder="剂量单位" id="MeasuringUnitName" class=" J_createSug">
                                    <datalist id="browsersss">
                                        @foreach (var item in MeasuringUnitmode)
                                        {
                                            <option value="@item.MeasuringUnitName" />
                                        }
                                    </datalist>

                                </div>
                            </div>
                            <div class="main-con-item col-md-4 sug-wrap normal-sug">
                                <span class="main-item-desc">使用频次：</span>
                                <input type="text" name="frequency" list="bowsers" id="DrugFrequencyName" class="J_createSug J_inputChar100">
                                <datalist id="bowsers">
                                    @foreach (var item in DrugFrequencymode)
                                    {
                                        <option value="@item.DrugFrequencyName" />
                                    }
                                </datalist>

                            </div>
                        </div>
                        <div class="main-con-col f-clrfix">
                            <div class="main-con-item col-md-4 short-input">
                                <span class="main-item-desc">默认开药量：</span>
                                <input type="text" name="prescribeAmount" maxlength="3" id="DrugUseOpenDose" placeholder="开药量" class="J_inputInt">
                            </div>
                            <div class="main-con-item col-md-4 sug-wrap">
                                <span class="main-item-desc J_doctorCharge">医嘱：</span>
                                <input type="text" name="doctorAdvice" class="J_createSug J_inputChar100" id="DocAdviceId">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<script src="~/Content/After/js/jquery.min.js"></script>
<script>
    $(function () {
        $("#ADD").click(function () {
            var DrugId = $("#DrugId").val()
            var OpenDoseName = $("#OpenDoseName").val();
            var DrugName = $("#DrugName").val();
            var DrugTypeId = $("#DrugTypeId").val();
            var DrugIsOtc = $("#DrugIsOtc").val();
            var DrugPackSpece = $("#DrugPackSpece").val();
            var DrugState = $("#DrugState").val();
            var ProductId = $("#ProductId").val();
            var DrugApprovalNo = $("#DrugApprovalNo").val();
            var DrugBarCode = $("#DrugBarCode").val();

            var DrugInvThrVal = $("#DrugInvThrVal").val();
            var DrugPurchasePrice = $("#DrugPurchasePrice").val();
            var DrugInvPresPrice = $("#DrugInvPresPrice").val();
            var SupplierId = $("#SupplierId").val();
            var tbDrugShelfCode = $("#tbDrugShelfCode").val();

            var DrugUsageName = $("#DrugUsageName").val();
            var DrugUseIdMeasu = $("#DrugUseIdMeasu").val();
            var MeasuringUnitName = $("#MeasuringUnitName").val();
            var DrugFrequencyName = $("#DrugFrequencyName").val();
            var DrugUseOpenDose = $("#DrugUseOpenDose").val();
            var DocAdviceId = $("#DocAdviceId").val();
            $.ajax({
                type: "post",
                url: "/DrupInfo/UptstDrupInfo",
                data: {
                    DrugId: DrugId,
                    DrugName: DrugName,
                    OpenDoseName: OpenDoseName,
                    DrugTypeId: DrugTypeId,
                    DrugIsOtc: DrugIsOtc,
                    DrugPackSpece: DrugPackSpece,
                    DrugState: DrugState,
                    ProductId: ProductId,
                    DrugApprovalNo: DrugApprovalNo,
                    DrugBarCode: DrugBarCode,
                    DrugPurchasePrice:DrugPurchasePrice,

                    DrugInvThrVal: DrugInvThrVal,
                    DrugInvPresPrice: DrugInvPresPrice,
                    SupplierId: SupplierId,
                    tbDrugShelfCode: tbDrugShelfCode,

                    DrugUseIdMeasu: DrugUseIdMeasu,
                    DrugUseOpenDose: DrugUseOpenDose,
                    DrugUsageName: DrugUsageName,
                    MeasuringUnitName: MeasuringUnitName,
                    DrugFrequencyName: DrugFrequencyName,
                    DocAdviceId: DocAdviceId
                },
                success: function (data) {
                    if (data > 0) {
                        location.href = "/DrupInfo/stDrupInfoIndex";
                        return;
                    } else {
                        alert("保存失败");
                        return;
                    }
                }
            })
        })
    })
</script>

